package sk.fritz.megafonsms.formmodel;

import java.util.Enumeration;
import java.util.Vector;

public class SelectFormControl extends AbstractFormControl {
	
	private Vector options = new Vector(10);
	
	private int selectedIndx;
	
	public void setSelectedIndx(int selectedIndx) {
		this.selectedIndx = selectedIndx;
		// update also value
		Option sel = (Option) options.elementAt(selectedIndx);
		setValue(sel.getValue());
	}
	
	public int getSelectedIndx() {
		return this.selectedIndx;
	}

	public void addOption(Option option) {
		options.addElement(option);
	}
	
	public Enumeration getOptions() {
		return options.elements();
	}
	
	public String[] getOptionTexts() {
		String[] res = new String[options.size()];
		Enumeration en = options.elements();
		int i = 0;
		while (en.hasMoreElements()) {
			Option o = (Option) en.nextElement();
			res[i++] = o.getText();
		}
		return res;
	}
	

}
